package styles 
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import util.Bounds;
	/**
	 * ...
	 * @author Kasoi
	 */
	public class TextButtonStyle
	{
		
		public function get positionMethod() : Function 
		{
			return this._positionMethod;
		}
		
		public function set positionMethod(value: Function) : void 
		{
			this._positionMethod = value;
		}
		
		public function get backgroundMethod() : Function 
		{
			return this._backgroundMethod;
		}
		
		public function set backgroundMethod(value: Function) : void 
		{
			this._backgroundMethod = value;
		}
		
		public var textNormalColor: Number = 0xffffff;
		
		public var textHoverColor: Number = 0xccff00;
		
		public var textActiveColor: Number = 0xffcc00;
		
		public var format: TextFormat = new TextFormat(Lib.defaultFont.fontName, 13, textNormalColor);
		
		public var buttonStyle: ButtonStyle = new ButtonStyle();
		
		public var title: TextField;
		
		private var _positionMethod: Function;
		
		private var _backgroundMethod: Function;
		
		public function defaultPositionMethod(title: TextField, background: DisplayObject, size: Bounds) : void
		{
			var tw: Number = title.width;
			var th: Number = title.height;
			var bw: Number = background.width;
			var bh: Number = background.height;
			var sw: Number = size.width;
			var sh: Number = size.height;
			
			title.x = sw / 2 - tw / 2;
			title.y = sh / 2 - th / 2;
			
			background.x = 0;
			background.y = 0;
		}
		
		public function defaultBackground(size: Bounds) : DisplayObject
		{
			var w: Number = size.width;
			var h: Number = size.height;
			
			var spr: Sprite = new Sprite();
			spr.graphics.beginFill(0x2273AC, 1);
			spr.graphics.drawRoundRect(0, 0, w, h, 6, 6);
			spr.graphics.endFill();
			return spr;
		}
		
		public function TextButtonStyle() 
		{
			this._backgroundMethod = this.defaultBackground;
			this._positionMethod = this.defaultPositionMethod;
		}
		
		public function drawBackground(size: Bounds) : DisplayObject
		{
			return this._backgroundMethod(size);
		}
		
	}

}